<template>
  <div class="brand">
    <div class="brand-title">
      <img class="img-width-max"  src="/static/img/home-brand.png">
    </div>
    <div class="zt-box">
      <router-link v-if="brandLeft.url" :to="brandLeft.url"><div class="img-default img1" :style="{backgroundImage:'url(' + brandLeft.path + ')'}"></div></router-link>
      <router-link :to="item.url" v-for="(item, index) of brandRight" :key="index"><div class="img-default" :class="index==0?'img2':'img3' " :style="{backgroundImage:'url(' + item.path + ')'}"></div></router-link>
    </div>
    <div class="members_con">
      <router-link v-if="brandBottom.url" :to="brandBottom.url"><img class="img-width-max" :src="brandBottom.path"></router-link>
      <img  v-if="!brandBottom.url" class="img-width-max" :src="brandBottom.path">
    </div>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  name: 'HomeBrand',
  data () {
    return {
      imgDe: true,
      brandLeft: [],
      brandRight: [],
      brandBottom: []
    }
  },
  methods: {
    getInfo () {
      axios.get('/meimai/interface/ad/getLeftBrandAd').then(this.getLeftBrandAd)
      axios.get('/meimai/interface/ad/getRightBrandAd').then(this.getRightBrandAd)
      axios.get('/meimai/interface/ad/getBottomBrandAd').then(this.getBottomBrandAd)
    },
    getLeftBrandAd (res) {
      res = res.data
      if (res.code === 0 && res.data) {
        this.brandLeft = res.data
      }
    },
    getRightBrandAd (res) {
      res = res.data
      if (res.code === 0 && res.data) {
        this.brandRight = res.data
      }
    },
    getBottomBrandAd (res) {
      res = res.data
      if (res.code === 0 && res.data) {
        this.brandBottom = res.data
      }
    }
  },
  mounted () {
    this.getInfo()
  }
}
</script>

<style lang="stylus" scoped>
  @import '~styles/mixins.styl'
  .brand
    .zt-box
      position: relative;
      padding-top: 50%;
      .img-default
        display: block
        position: absolute
        background-size: cover
        background-position: center
        background-repeat: no-repeat
        width: 50%;
      .img1
        top: 0
        left: 0
        height: 100%
      .img2
        top: 0
        right: 0
        height: 50%
      .img3
        bottom: 0
        right: 0
        height: 50%
</style>
